<html>
    <body>
        <div class="container">
            <button type="button" onclick="test1()">测试1</button>
            <button type="button" onclick="test2()">测试2</button>
            <button type="button" onclick="test3()">测试3</button>
            <button type="button" onclick="test4()">测试4</button>
        </div>
        <div style="width: 300px;height: 200px;">
                <p id="input">1</p>
        </div>
    </body>
</html>
<script>
    function test1(){
        let arr = initArr()
        arr.forEach(item=>{
            console.log(item)
        })
        for(let item of arr){
            console.log(item)
        }
        document.getElementById('input').innerHTML= JSON.stringify(arr)
    }
    function initArr(){
        let arr =[]
        let obj1 = {name:'a',age:'1'}
        let obj2 = {name:'b',age:'2'}
        let obj3 = {name:'c',age:'3'}
        let obj4 = {name:'d',age:'4'}
        let obj5 = {name:'e',age:'5'}
        arr.push(obj1)
        arr.push(obj2)
        arr.push(obj3)
        arr.push(obj4)
        arr.push(obj5)
        return arr
    }

    // 数组 增删改查
    function test2(){
        let arr = initArr()
        let obj = {name:'00',age:'00'}
        // arr.splice(1,0,obj)
        arr.splice(2)

        printText(arr)
    }


    function printText(val){
        document.getElementById('input').innerHTML= JSON.stringify(val)
    }

    // 获取 url
    function url(param1){
        return function(param2,param3){
            return `${param1}${param2}${param3}`
        }
    }
    let myurl = url('test1');
    let myurl1 = myurl('test2','test3')
    let myurl2 = myurl('test4')

    // `async`函数返回一个`promise`对象
    test3 = function(){
        return Promise.resolve('test')
    }
    async function test4 (){
        return 'test'
    }

    async function test5(){
        // 等同于 return 123
        return await 123
    }
    test5().then(res=>console.log(res))

</script>